package com.example.demo.Mapper;

import com.example.demo.Entity.User;
import com.example.demo.Entity.transfer.UserDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface UserMapper {
    //根据手机号查用户信息
    @Select("select * from user where phone=#{phone}")
    User getUserInfoByPhone(@Param("phone") String phone);


    //获取全部用户信息
    @Select("select * from user ")
    User getUserInfo();


    //获取用户登陆信息
    @Select("select * from user where phone=#{phone} and  password=#{password}")
    User getUserInfoforLogin(@Param("phone") String phone,@Param("password") String password);


    //新增用户
    @Insert("INSERT INTO USER (phone,passWord,realName,age,sex,address,role,create_time) VALUES(#{phone},#{passWord}," +
            "#{realName},#{age},#{sex},#{address},#{role},NOW())")
    int addUser(UserDTO userDTO);

}
